{% extends "rules/base.html" %}
{% block sidebar %}
    <div class="panel-heading">
        <h2 class="panel-title">
            {% if name|slice:'-1:' == 'y' %}
                {{ name|slice:':-1' }}{{ size|pluralize:"y,ies" }}
            {% else %}
                {{ name }}{{ size|pluralize }}
            {% endif %}
        </h2>
    </div>
    <ul class="panel-body">
        <li>{{ size }} object{{ size|pluralize }}</li>
    </ul>
    {% if manage_links %}
        <div class="panel-heading">
            <h2 class="panel-title">Manage {{ name }}</h2>
        </div>
        <ul class="panel-body">
            {% for url, title in manage_links.items  %}
                <li>
                    <a href="{% url url  %}">{{ title }}</a>
                </li>
            {% endfor %}
        </ul>
    {% endif %}
    {% if action != 'Recurrent Task' %}
        <!-- No action for Reccurent Tasks -->
        <div class="panel-heading">
            <h2 class="panel-title">Action{% if adduri and action_links|length > 0 %}s{% endif %}</h2>
        </div>
        {% if adduri %}
            <ul class="action panel-body">
                <li>
                    <a href="{{ adduri }}">Add {{ action }}</a>
                </li>
                {% for url, title in action_links.items  %}
                    <li>
                        <a href="{% url url  %}">{{ title }}</a>
                    </li>
                {% endfor %}
            </ul>
        {% else %}
            <ul class="action panel-body">
                <li>
                    <a href="{% url 'rules_index' %}{{ action }}/add">Add</a>
                </li>
            </ul>
        {% endif %}
    {% endif %}
{% endblock %}
{% block content %}
    {% if objects %}
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-8">
                <h2 class="title">
                    {% if action.lower|slice:"-1:" != 'y' %}
                        {{ action.title }}{{ size|pluralize }}
                    {% else %}
                        {{ action.title|slice:":-1" }}{{ size|pluralize:"y,ies" }}
                    {% endif %}
                </h2>
                    {% load render_table from django_tables2 %}
                    {% render_table objects %}
                </div>
            </div>
        </div>
    {% else %}
        No object available.
    {% endif %}
{% endblock %}
